#ifndef _MT5_GAME_H_
#define _MT5_GAME_H_

#include "wds_define.h"
#include "wds_player.h"

#include "ui/ui_number.h"
#include "editor/editor_main.h"
#include "input/keyboard.h"
#include "input/mouse.h"
#include "ui/ui_sprite.h"
#include "part2d/part2d.h"


class WDSGameEditor;
class GENGameState;

namespace gameflow
{
	class UIPopup;
};

using namespace editor;

class WDSGame : public GameBase
{
public:



	WDSGame(GENGameState* pGameState, const math::Vec2& MinBoundary, const math::Vec2& MaxBoundary);
	~WDSGame();

	struct GameSpeed		// slow motion
	{
		bool	m_IsActivate;
		float	m_CurrentTickScale;
		bool	m_IsGoingDown;
		float	m_Counter;

		GameSpeed() :	m_IsActivate(false),
						m_IsGoingDown(false),
						m_CurrentTickScale(1.0f),
						m_Counter(0)
		{}


		void	Activate();
		float	Tick(float dt);
		

	};

	
	void						Render(const math::Vec2& Offset);
	void						RenderDebug(const math::Vec2& Offset);
	void						PostRender();		
	//void						RenderOverUI();
	void						Tick(float dt, const math::Vec2& Offset);
	
	void						KeyPressed(input::Keyboard::KEY* pKey);								
	void						MouseButtonDown(input::Mouse::BUTTON_STATE* pKey, const math::Vec2& Pos);
	void						MouseButtonReleased(input::Mouse::BUTTON_STATE* pKey, const math::Vec2& Pos);

	void						MouseButtonPressed(input::Mouse::BUTTON_STATE* pKey, const math::Vec2& Pos);	
	void						MouseMove(const math::Vec2& From, const math::Vec2& To);
	void						MouseWheelMove(int WheelInfo, const math::Vec2& Pos);

	virtual bool				Save(const std::string& File);	// save to filename
	virtual bool				Load(const std::string& File);		// load from filename
	virtual bool				Clear();		// clear everything in the game
	void						ClearRenderList();


	void						SetPausePopup(gameflow::UIPopup* pPopup) { m_pUIPause = pPopup; };
	
	
	//void						SetBackGround();
	float						GetScale() const { return m_Scale; };
	//void						GetOffset(math::Vec2& Temp) const { Temp = m_Offset; };

	void						AnimateHideBoard(float Delay);
	void						AnimateShowBoard(float Delay);	
	
	void						UpdateOffset(const math::Vec2& PlayerPos);
	WDSPlayer*					GetPlayer() { return &m_Player; };
	void						ActivateSlowmotion() { m_GameSpeed.Activate(); }

protected:
	
	
	GENGameState*				m_pGameState;
	float						m_Scale;

	math::Vec2					m_SizeGem;
	math::Vec2					m_SizeGemSmall;	

			
	WDSGameEditor*				m_pEditor;		
	math::Vec2					m_AspectScale;	

	
	gameflow::UIPopup*			m_pUIPause;
	gameflow::UIPopup*			m_pUISetting;	
	WDSPlayer					m_Player;					
	GameSpeed					m_GameSpeed;

	float						m_NextEnemySpawn;
	float						m_CurrentEnemySpawnRate;
	float						m_TimeDifficulty;

};






#endif // _MT5_GAME_H_